#define _CRT_SECURE_NO_WARNINGS 1

#include"Stack.h"
bool isValid(char* s) {
    Stack ST;
    StackInit(&ST);
    while (*s)
    {
        if (*s == '(' || *s == '{' || *s == '[')
        {
            StackPush(&ST, *s);
        }
        else
        {
            if (StackSize(&ST) == 0)
            {
                StackDestroy(&ST);
                return false;
            }
            int top = StackTop(&ST);
            StackPop(&ST);
            if ((*s == ')' && top != '(') ||
                (*s == ']' && top != '[') ||
                (*s == '}' && top != '{'))
            {
                StackDestroy(&ST);
                return false;
            }
        }
        s++;
    }
    if (StackSize(&ST) != 0)
    {
        StackDestroy(&ST);
        return false;
    }
    return true;

}
int main()
{
    printf("%d", isValid("()"));
	return 0;
}